package com.example.demo.service.impl;

import com.example.demo.entity.AuthAccountLog;
import com.example.demo.mapper.AuthAccountLogMapper;
import com.example.demo.service.AuthAccountLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 登录注册登出记录(AuthAccountLog)表服务实现类
 *
 * @author ElonChung
 * @since 2020-05-11 18:35:30
 */
@Service("AuthAccountLogService")
public class AuthAccountLogServiceImpl implements AuthAccountLogService {
    @Resource
    private AuthAccountLogMapper authAccountLogMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AuthAccountLog queryById(Integer id) {
        return authAccountLogMapper.queryById(id);
    }

    /**
     * 根据条件查询多条数据
     *
     * @return 对象列表
     */
    @Override
    public List<AuthAccountLog> queryAllByCondition(AuthAccountLog authAccountLog) {
        return authAccountLogMapper.queryAll(authAccountLog);
    }

    /**
     * 新增数据
     *
     * @param authAccountLog 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional
    public AuthAccountLog insert(AuthAccountLog authAccountLog) {
        this.authAccountLogMapper.insert(authAccountLog);
        return authAccountLog;
    }

    /**
     * 修改数据
     *
     * @param authAccountLog 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional
    public AuthAccountLog update(AuthAccountLog authAccountLog) {
        this.authAccountLogMapper.update(authAccountLog);
        return queryById(authAccountLog.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return authAccountLogMapper.deleteById(id) > 0;
    }
}